<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use Hyperf\HttpServer\Contract\RequestInterface;
use Qbhy\HyperfAuth\AuthManager;
use Qbhy\HyperfAuth\Guard\JwtGuard;
use Psr\Container\ContainerInterface;
use Qbhy\HyperfAuth\Provider\EloquentProvider;
use Qbhy\HyperfAuth\UserProvider;

return [


    EloquentProvider::class => function (ContainerInterface $container) {
        $config = $container->get(\Hyperf\Contract\ConfigInterface::class)->get('auth.providers.users');
        $model = $config['model'];

        return new EloquentProvider($config, $model);
    },

        AuthManager::class => function (ContainerInterface $container) {

            var_dump('我进来了');
            $config = $container->get(\Hyperf\Contract\ConfigInterface::class);
            return new AuthManager($config);
        },
        JwtGuard::class => function (ContainerInterface $container) {

            $config = $container->get(\Hyperf\Contract\ConfigInterface::class)->get('auth.guards.jwt');

            var_dump($config);
            if ($config === null) {
                throw new \RuntimeException('JWT config not found.');
            }

            $userProvider = $container->get(EloquentProvider::class);

            $requestInterface = $container->get(RequestInterface::class);


            return new JwtGuard($config,'jwt',$userProvider,$requestInterface);
        },

];
